package top.shiyiri.spring5.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.shiyiri.spring5.dao.BookDao;
import top.shiyiri.spring5.entity.Book;

import java.util.List;

/**
 * @author Aunean
 * @date 2022/2/18 14:25
 */
@Service
public class BookService {

    @Autowired
    private BookDao bookDao;

    //添加的方法
    public void add(Book book) {
        bookDao.add(book);
    }

    //修改的方法
    public void update(Book book) {
        bookDao.updateBook(book);
    }

    //删除的方法
    public void delete(String id) {
        bookDao.deleteBook(id);
    }

    //查询表记录数
    public int findCount() {
        return bookDao.selectCount();
    }

    //查询对象
    public Book findOne(String id) {
        return bookDao.findBookInfo(id);
    }

    //查询对象集合
    public List<Book> findList() {
        return bookDao.findAllBook();
    }

    //批量添加
    public void batchAdd(List<Object[]> batchArgs) {
        bookDao.batchAddBook(batchArgs);
    }

    //批量修改
    public void batchUpdateBook(List<Object[]> batchArgs) {
        bookDao.batchUpdateBook(batchArgs);
    }

    //批量删除
    public void batchDelete(List<Object[]> batchArgs) {
        bookDao.batchDeleteBook(batchArgs);
    }
}
